/*
 * tire-agent-blocks/post-slider — self-contained styles
 * (specs/blocks-self-contained-css.md). Mirrors the theme's
 * blocks/post-swiper.css (flattened; the `.posts`-scoped rules also ship
 * unscoped so the slider styles on surfaces without the blog wrapper).
 * Fix beyond the theme copy: at in-post column width the theme's desktop
 * media queries still fire (they key on the viewport), squeezing the title
 * into a 45%-wide panel at 45px ("What Are Run-…") and letting the slide
 * image escape the card radius — a container query on the block wrapper
 * restores the stacked mobile presentation whenever the block itself is
 * narrow, regardless of viewport.
 */

:root {
  --ta-post-swiper-height: 560px;
  --ta-post-swiper-height-min: 480px;
  --ta-post-swiper-control-size: 60px;
  --ta-post-swiper-padding: 20px;
  --ta-color-swiper-dot: var(--ta-color-neutral-300);
  --ta-color-swiper-dot-active-mobile: #FFFFFF;
  --ta-color-swiper-dot-active-desktop: #FFFFFF;
}

.site-column.tire-agent-blocks__post-slider {
  position: relative;
  border-radius: 20px;
  margin: 0 auto;
  container-type: inline-size;
  container-name: ta-post-slider;
}

.ta-post-swiper,
.posts .ta-post-swiper {
  position: relative;
  border-radius: 20px;
}

.ta-post-swiper__details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-inline: var(--ta-post-swiper-padding);
  padding-block-start: var(--ta-post-swiper-padding);
  padding-block-end: calc(var(--ta-post-swiper-padding) * 4);
  margin-block-start: auto;
  margin-top: auto;
  background-color: var(--ta-color-neutral-900);
  text-align: center;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  position: relative;
  bottom: 0;
}

.ta-post-swiper__details > * {
  color: var(--ta-color-neutral-100) !important;
}

.ta-post-swiper__controls {
  display: none;
  visibility: hidden;
  position: relative;
}

.ta-post-swiper__title,
.ta-post-swiper__excerpt {
  color: var(--ta-color-neutral-100) !important;
  text-align: center;
}

.ta-post-swiper__title {
  margin: 0;
  padding: 0 !important;
  font-family: var(--ta-font-family);
  font-style: normal;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.21;
  text-transform: none;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ta-post-swiper__title:before {
  display: none;
}

.ta-post-swiper__excerpt {
  font-size: 16px;
  line-height: 1.25;
  min-height: 3.75em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* have to get specific to override swiper styles */
.ta-post-swiper .ta-post-swiper__post {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background-repeat: no-repeat;
  background-position: center top;
  background-size: contain;
  border-radius: 20px;
  overflow: hidden;
  height: var(--ta-post-swiper-height);
}

.swiper.ta-post-swiper {
  overflow: hidden;
  border-radius: 20px;
}

.ta-post-swiper .swiper-wrapper {
  overflow: visible;
}

/* swiper nav (dots) */
.ta-post-swiper > .ta-post-swiper-nav:has(span) {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: unset;
  left: 0;
  right: 0;
  bottom: 30px;
  width: 100%;
  padding: 4px;
  z-index: 5;
}

.ta-post-swiper > .ta-post-swiper-nav:has(span) > * {
  width: 10px;
  height: 10px;
  margin: 0 5px;
  border-radius: 100%;
  background-color: var(--ta-color-neutral-400);
  opacity: 1;
}

.ta-post-swiper > .ta-post-swiper-nav:has(span) > *[class*="active"],
.ta-post-swiper > .ta-post-swiper-nav--inverse:has(span) > *[class*="active"] {
  background-color: var(--ta-color-swiper-dot-active-mobile);
}

/* desktop presentation — only when the block itself is wide */
@container ta-post-slider (min-width: 900px) {
  .ta-post-swiper,
  .posts .ta-post-swiper {
    --ta-post-swiper-padding: 60px;
    min-height: var(--ta-post-swiper-height-min);
  }

  .ta-post-swiper__details {
    flex-basis: 45%;
    align-items: flex-start;
    justify-content: center;
    margin-block-start: 0;
    margin-top: 0;
    padding: var(--ta-post-swiper-padding);
    text-align: left;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    bottom: auto;
  }

  .ta-post-swiper__excerpt,
  .ta-post-swiper__title {
    text-align: left;
  }

  .ta-post-swiper__excerpt > * {
    font-size: 20px;
    line-height: 1.4;
  }

  .ta-post-swiper__title {
    font-size: 45px !important;
    line-height: 1.1 !important;
  }

  .ta-post-swiper__button {
    margin-block-start: 20px;
  }

  .ta-post-swiper__controls {
    display: block;
    visibility: visible;
  }

  .ta-post-swiper__next,
  .ta-post-swiper__prev {
    align-content: center;
    text-align: center;
    visibility: visible;
    display: block;
    position: absolute;
    bottom: calc((var(--ta-post-swiper-height-min) / 2) + (var(--ta-post-swiper-control-size) / 2));
    width: var(--ta-post-swiper-control-size);
    height: var(--ta-post-swiper-control-size);
    border-radius: 100%;
    background-color: var(--ta-color-neutral-100);
    box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.20);
    font-size: 1.5rem;
    color: var(--ta-color-neutral-400);
    transition: color 200ms ease;
    z-index: 10;
    cursor: pointer;
    transform: translateY(30px);
  }

  .ta-post-swiper__next:hover,
  .ta-post-swiper__prev:hover,
  .ta-post-swiper__next:active,
  .ta-post-swiper__prev:active {
    color: var(--ta-color-neutral-900);
  }

  .ta-post-swiper__prev {
    left: -24px;
  }

  .ta-post-swiper__next {
    right: -24px;
  }

  .ta-post-swiper .ta-post-swiper__post {
    min-height: var(--ta-post-swiper-height);
    flex-direction: row;
    justify-content: flex-start;
    background-position: right bottom;
    background-size: contain;
  }

  /* desktop dots aligned with the Read More button */
  .ta-post-swiper > .ta-post-swiper-nav:has(span) {
    justify-content: flex-start;
    left: var(--ta-post-swiper-padding);
    right: auto;
    width: auto;
    z-index: 10;
  }

  .ta-post-swiper > .ta-post-swiper-nav:has(span) > *[class*="active"],
  .ta-post-swiper > .ta-post-swiper-nav--inverse:has(span) > *[class*="active"] {
    background-color: var(--ta-color-swiper-dot-active-desktop);
  }

  .site-column.tire-agent-blocks__post-slider {
    margin: 0 auto;
    padding: 0 var(--ta-site-gutter);
  }
}

/* narrow-column fix: the theme's viewport media queries (loaded alongside on
   blog surfaces) force the desktop split layout even when the block sits in a
   ~700px post column — pin the stacked presentation when the block is narrow */
@container ta-post-slider (max-width: 899px) {
  .ta-post-swiper,
  .posts .ta-post-swiper {
    --ta-post-swiper-padding: 20px;
    min-height: unset;
  }

  .tire-agent-blocks__post-slider .ta-post-swiper__details,
  .posts .ta-post-swiper .ta-post-swiper__details {
    flex-basis: auto !important;
    width: 100% !important;
    align-items: center !important;
    justify-content: flex-start !important;
    margin-block-start: auto !important;
    padding: 20px 20px 80px !important;
    text-align: center !important;
    border-bottom-left-radius: 20px !important;
    border-bottom-right-radius: 20px !important;
  }

  .tire-agent-blocks__post-slider .ta-post-swiper__title,
  .posts .ta-post-swiper .ta-post-swiper__title {
    font-size: 28px !important;
    line-height: 1.21 !important;
    text-align: center !important;
  }

  .tire-agent-blocks__post-slider .ta-post-swiper__excerpt,
  .posts .ta-post-swiper .ta-post-swiper__excerpt {
    text-align: center !important;
  }

  .tire-agent-blocks__post-slider .ta-post-swiper__controls,
  .posts .ta-post-swiper .ta-post-swiper__controls {
    display: none !important;
    visibility: hidden !important;
  }

  /* keep the slide image inside the card's rounded bounds */
  .tire-agent-blocks__post-slider .swiper.ta-post-swiper,
  .posts .swiper.ta-post-swiper {
    overflow: hidden !important;
    border-radius: 20px !important;
  }

  /* stacked slide: image on top, details band at the bottom (the theme's
     desktop media query forces the row split at any viewport ≥1024px) */
  .tire-agent-blocks__post-slider .ta-post-swiper .ta-post-swiper__post,
  .posts .ta-post-swiper .ta-post-swiper__post {
    flex-direction: column !important;
    justify-content: flex-end !important;
    background-position: center top !important;
    background-size: contain !important;
    min-height: unset !important;
    height: var(--ta-post-swiper-height) !important;
  }

  /* dots back to the centered mobile position */
  .tire-agent-blocks__post-slider .ta-post-swiper > .ta-post-swiper-nav:has(span),
  .posts .ta-post-swiper > .ta-post-swiper-nav:has(span) {
    justify-content: center !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }
}
